/* 
 * Copyright 2014-2021 UME Framework, GNU General Public License 
 */
package com.u2framework.lib.tool.poi;

import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.CellType;

/**
 * SimpleCellWriter
 * 
 * @author SultansOfSwing & MaYue
 */
public class SimpleCellWriter implements CellWriter<Object> {

    /*
     * (non-Javadoc)
     * 
     * @see org.umeframework.dora.tool.util.poi.CellWriter#writer(org.apache.poi.ss. usermodel.Cell, java.lang.Object)
     */
    @SuppressWarnings("deprecation")
    @Override
    public void write(Cell cell, Object value) {
        if (value instanceof Number) {
            cell.setCellType(CellType.NUMERIC);
            cell.setCellValue(Double.valueOf(String.valueOf(value)));
        } else {
            cell.setCellType(CellType.STRING);
            cell.setCellValue(String.valueOf(value));
        }
    }

}
